﻿@{
    ViewBag.Title = "编辑实例信息";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <style>
        .pagTable td
        {
            padding-left: 3px;
        }
    </style>
    <script type="text/javascript">
        var UrlArray = $.getUrlArray();
        $(function () {
            $(".dbName").html(UrlArray["dbName"]);
            $(".displayName").html(UrlArray["DisplayName"]);
            switch (UrlArray["mm"]) {
                case "3":
                    GetDBInfo(UrlArray["dbName"]);
                    $("#mm3").show();
                    break;
                case "4":
                    $("#mm4").show();
                    break;
                case "5":
                    $("#mm5").show();
                    break;
                case "6":
                    $("#mm6").show();
                    break;
            }
        })
        function GetDBInfo(n) {
            $.post("/Home/DBInfo?dbName=" + encodeURI(n), function (data) {
                $("#dbInfo").html(data);
            })
        }
        function RenameDB() {
            $(".loading").show();
            $.post("/Home/RenameDB", { dbName: UrlArray["dbName"], newDBName: $("#txt_NewDBName").val() }, function (data) {
                if (data == "1") {
                    $(".loading").hide();
                    alert("重命名成功！");
                    var parent = window.dialogArguments; //获取父页面参数 
                    parent.TreeReload();
                    window.close();
                }
                else
                    $(".msg").html(data);
                $(".loading").hide();
            })
        }
        function SHRINKDATABASE() {
            if (confirm("确定要收缩数据库？")) {
                $(".loading").show();
                $.post("/Home/SHRINKDATABASE?dbName=" + encodeURI(UrlArray["dbName"]), function (data) {
                    $(".loading").hide();
                    $(".msg").html(data);
                })
            }
        }
        function DBREINDEX() {
            if (confirm("确定要重新生成索引？")) {
                $(".loading").show();
                $.post("/Home/DBREINDEX?dbName=" + encodeURI(UrlArray["dbName"]), function (data) {
                    $(".loading").hide();
                    $(".msg").html(data);
                })
            }
        }
    </script>
}
<div style="margin: 5px;">
    <div id="mm3" style="display: none;">
        <table class="listTitle">
            <tr>
                <td width="15">
                    <img src="/images/edit.png" />
                </td>
                <td width="100">
                    数据库属性
                </td>
                <td align="right">
                </td>
            </tr>
        </table>
        <div id="dbInfo" style="height: 150px; overflow-x: scroll;">
        </div>
        <div class="loading">
            <img src="/Images/tree_loading.gif" />
        </div>
    </div>
    <div id="mm4" style="display: none;">
        <table class="listTitle">
            <tr>
                <td width="15">
                    <img src="/images/edit.png" />
                </td>
                <td width="100">
                    收缩数据库
                </td>
                <td align="right">
                    <input type="button" class="button" value="执行" onclick="SHRINKDATABASE()" />
                </td>
            </tr>
        </table>
        <table class="searchArea" width="100%">
            <tr>
                <td>
                    通过收缩所有数据库文件释放未使用的空间，可以减小数据库的大小。
                </td>
            </tr>
            <tr>
                <td>
                    实例名：<span class="displayName"></span>
                </td>
            </tr>
            <tr>
                <td>
                    数据库：<span class="dbName"></span>
                </td>
            </tr>
            <tr>
                <td height="85" valign="top">
                    <div class="msg">
                    </div>
                    <div class="loading">
                        <img src="/Images/tree_loading.gif" />
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div id="mm5" style="display: none;">
        <table class="listTitle">
            <tr>
                <td width="15">
                    <img src="/images/edit.png" />
                </td>
                <td width="100">
                    重新生成索引
                </td>
                <td align="right">
                    <input type="button" class="button" value="执行" onclick="DBREINDEX()" />
                </td>
            </tr>
        </table>
        <table class="searchArea" width="100%">
            <tr>
                <td>
                    实例名：<span class="displayName"></span>
                </td>
            </tr>
            <tr>
                <td>
                    数据库：<span class="dbName"></span>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;&nbsp;&nbsp;对象：表和视图
                </td>
            </tr>
            <tr>
                <td height="85" valign="top">
                    <div class="msg">
                    </div>
                    <div class="loading">
                        <img src="/Images/tree_loading.gif" />
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div id="mm6" style="display: none;">
        <table class="listTitle">
            <tr>
                <td width="15">
                    <img src="/images/edit.png" />
                </td>
                <td width="100">
                    重命名实例名称
                </td>
                <td align="right">
                    <input type="button" class="button" value="保存" onclick="RenameDB()" />
                </td>
            </tr>
        </table>
        <table class="searchArea" width="100%">
            <tr>
                <td style=" padding-left:25px;">
                    原实例名：<span class="displayName"></span>
                </td>
            </tr> 
            <tr> 
                <td  style=" padding-left:25px;" height="80" valign="top">
                    新实例名：<input type="text" id="txt_NewDBName" />
                    <div class="msg">
                    </div>
                    <div class="loading">
                        <img src="/Images/tree_loading.gif" />
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
